package July;

import java.util.Scanner;

public class Day0729 {
    //统计每个月兔子的总数
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dp = new int[n+1];

        //处理兔子数量
        dp[0] = 0;
        dp[1] = 1;
        dp[2] = 1;
        for (int i = 3; i <= n; i++) {
            dp[i] = dp[i-1]+dp[i-2];
        }
        System.out.println(dp[n]);
    }



    //字符串通配符
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //带有通配符的字符串
        String s1 = scanner.nextLine();
        //需要进行匹配的字符串
        String s2 = scanner.nextLine();

        System.out.println(pipei(s1,s2,0,0));
    }

    private static boolean pipei(String s1, String s2, int i, int i1) {
        if (i == s1.length() && i1 == s2.length())
            return true;
        if (i == s1.length() || i1 == s2.length())
            return false;

        if (s1.charAt(i) == '?')
            return pipei(s1,s2,i+1,i1+1);
        else if (s1.charAt(i) == '*') {
            return pipei(s1,s2,i+1,i1) || pipei(s1,s2,i,i1+1) || pipei(s1,s2,i+1,i1+1);
        } else if (s1.charAt(i) == s2.charAt(i1)) {
            return pipei(s1,s2,i+1,i1+1);
        }else {
            return false;
        }
    }
}
